﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <script src="~/js/frame.js"></script>
</head>
<body>
    <div class="framecontainer">
        <div class="listcontainer">
            <div class="searchop">
                <div class="btnop">
                    <button class="btn btn-op" type="button" onclick="OpenAdd()"><span class="btntext">新增子项</span></button>
                    <button class="btn btn-op" type="button" onclick="BatchDelete()"><span class="btntext">批量删除</span></button>
                </div>
                <div class="btnop">
                    <span class="searchtext">代码文字:</span><input id="ItemName" type="text" class="form-control searchinput" placeholder="请输入代码文字">
                    <span class="searchtext">代码值:</span><input id="ItemValue" type="text" class="form-control searchinput" placeholder="请输入代码值">
                    <button class="btn" type="button" onclick="BindGrid()"><i class="icon icon-search"></i><span class="searchtext">查询</span></button>
                </div>
            </div>
            <div class="tableop">
                <table class="GridStyle" id="CloudGrid" keyid="ItemGuid" url="oplist" relationpageid="cloudpagination" otherparm="SearchParm" afterbind="AfterBindData">
                    <tr class="HeaderStyle">
                        <th scope="col" style="width: 10px;" field="check" rowalign="center"></th>
                        <th scope="col" style="width: 10px;" field="index" rowalign="center">序</th>
                        <th scope="col" field="ItemName" rowalign="left">文字</th>
                        <th scope="col" field="ItemValue" rowalign="left">值</th>
                        <th scope="col" style="width: 50px;" field="SortNum" rowalign="center">排序</th>
                        <th scope="col" style="width: 50px;" field="EditButton" functionname="GridEdit" rowalign="center">详细</th>
                    </tr>
                </table>
            </div>
            <div class="bottomop">
                <div class="pageop">
                    <ul class="pagination" id="cloudpagination"></ul>
                </div>
            </div>
        </div>
    </div>
    <script>
        var LevelType = GetUrlParam("leveltype")
        $(function () {
            BindGrid();
        })
        function BindGrid() {
            BindCloudGrid($("#CloudGrid"))
        }

        function SearchParm() {
            return {
                "ItemValue": $("#ItemValue").val(),
                "ItemName":$("#ItemName").val(),
                "MainGuid": GetUrlParam("mainguid")
            };
        }
        function AfterBindData() {

        }
        function OpenAdd() {
            if (LevelType == "10") {
                OpenTopDialog("新增子项", "frame/dmp/codeitem/add?mainguid=" + GetUrlParam("mainguid"), 400, 800, BindGrid)
            } else {
                OpenTopDialog("新增子项", "frame/dmp/codeitem/moreleveladd?mainguid=" + GetUrlParam("mainguid"), 400, 800, BindGrid)
            }

        }
        function BatchDelete() {
            var SelectRows = CloudGridChecked($("#CloudGrid"));
            if (SelectRows.length > 0) {
                OpenConfirm("确认删除选中的数据？", function () {
                    CloudPost({ "KeyID": SelectRows }, "opbatchdelete", function (res) {
                        if (res.code == 0) {
                            OpenSuccess("删除成功！", function () {
                                BindGrid();
                            })
                        } else {
                            OpenFail(res.data);
                        }
                    })
                })
            }
        }
        function GridEdit(RowData) {
            if (LevelType == "10") {
                OpenTopDialog("编辑", "frame/dmp/codeitem/edit?itemguid=" + RowData.ItemGuid, 400, 800, BindGrid)
            } else {
                OpenTopDialog("编辑", "frame/dmp/codeitem/moreleveledit?itemguid=" + RowData.ItemGuid, 400, 800, BindGrid)
            }

        }
    </script>
</body>
</html>
